package thread;
/*第二种创建线程的方式
1、实现runnable接口
重写run方法
相当于单独定义线程任务
 */
public class ThreadDemo02 {
    public static void main(String[] args) {
        //单独实例化希望并发执行的任务
       Runnable runnable1 = new MyRunnable1();
       Runnable runnable2 = new MyRunnable2();
       //创建两条线程分别执行各自的任务
        Thread t1 = new Thread(runnable1);
        Thread t2 = new Thread(runnable2);
        t1.start();
        t2.start();
    }
}
class MyRunnable1 implements Runnable{

    @Override
    public void run() {
        for (int i=0; i<1000; i++){
            System.out.println("你是谁");
        }
    }
}
class MyRunnable2 implements Runnable{

    @Override
    public void run() {
        for (int i=0; i<1000; i++){
            System.out.println("查水表的");
        }
    }
}